Skip to content

Unit overhaul 1/6: Add unit-conversion utilities and FitTarget#221

Open
henrikjacobsenfys wants to merge 3 commits into
developfrom
split/01-unit-utils
Open

Unit overhaul 1/6: Add unit-conversion utilities and FitTarget#221
henrikjacobsenfys wants to merge 3 commits into
developfrom
split/01-unit-utils

Conversation

@henrikjacobsenfys

@henrikjacobsenfys henrikjacobsenfys commented Jul 6, 2026

Copy link
Copy Markdown
Member

Additive foundation for the unit-system overhaul, split out of the larger branch so it can be reviewed and merged on its own.

  • utils.py: add convert_value_unit, convert_parameter_unit, convert_units_with_rollback, energy_to_scipp, verify_Q_index and _assert_valid_unit helpers, plus the kb constant and CANONICAL_Q_UNIT. No behavior change to existing functions.
  • fit_target.py: new FitTarget dataclass describing one fittable model prediction bound to a dataset key.
  • test_utils.py: tests for the new helper functions.

All unit tests pass.


Stack — splitting the monolithic "Unit system overhaul" (#217) into a reviewable series. Merge bottom-up:

  1. Add unit-conversion utilities and FitTargetdevelop (Unit overhaul 1/6: Add unit-conversion utilities and FitTarget #221) (this PR)
  2. Centralize Q-index validation via verify_Q_indexsplit/01-unit-utils (Unit overhaul 2/6: Centralize Q-index validation via verify_Q_index #222)
  3. Store Q as a scipp Variable in 1/angstrom → split/02a-verify-q-index (Unit overhaul 3/6: Store Q as a scipp Variable in 1/angstrom #223)
  4. Separate model unit into x_unit/y_unit + update tutorials → split/02b-q-variable (Unit overhaul 4/6: Separate unit into x_unit/y_unit and update tutorials #224)

🤖 Generated with Claude Code

Additive foundation for the unit-system overhaul, split out of the larger
branch so it can be reviewed and merged on its own.

- utils.py: add convert_value_unit, convert_parameter_unit,
  convert_units_with_rollback, energy_to_scipp, verify_Q_index and
  _assert_valid_unit helpers, plus the kb constant and CANONICAL_Q_UNIT.
  No behavior change to existing functions.
- fit_target.py: new FitTarget dataclass describing one fittable model
  prediction bound to a dataset key.
- test_utils.py: tests for the new helper functions.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@henrikjacobsenfys henrikjacobsenfys added [scope] enhancement Adds/improves features (major.MINOR.patch) [priority] medium Normal/default priority labels Jul 6, 2026
@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.92%. Comparing base (6de7065) to head (e79b9d7).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #221      +/-   ##
===========================================
+ Coverage    97.89%   97.92%   +0.03%     
===========================================
  Files           52       53       +1     
  Lines         3653     3707      +54     
  Branches       650      660      +10     
===========================================
+ Hits          3576     3630      +54     
  Misses          45       45              
  Partials        32       32              
Flag Coverage Δ
unittests 97.92% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/easydynamics/utils/fit_target.py 100.00% <100.00%> (ø)
src/easydynamics/utils/utils.py 98.86% <100.00%> (+1.08%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@henrikjacobsenfys henrikjacobsenfys changed the title Unit overhaul 1/5: Add unit-conversion utilities and FitTarget Unit overhaul 1/4: Add unit-conversion utilities and FitTarget Jul 6, 2026
@henrikjacobsenfys henrikjacobsenfys changed the title Unit overhaul 1/4: Add unit-conversion utilities and FitTarget Unit overhaul 1/6: Add unit-conversion utilities and FitTarget Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[priority] medium Normal/default priority [scope] enhancement Adds/improves features (major.MINOR.patch)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant